
<h1><span class="yiyi-st" id="yiyi-12">numpy.zeros_like</span></h1>
        <blockquote>
        <p>原文：<a href="https://docs.scipy.org/doc/numpy/reference/generated/numpy.zeros_like.html">https://docs.scipy.org/doc/numpy/reference/generated/numpy.zeros_like.html</a></p>
        <p>译者：<a href="https://github.com/wizardforcel">飞龙</a> <a href="http://usyiyi.cn/">UsyiyiCN</a></p>
        <p>校对：（虚位以待）</p>
        </blockquote>
    
<dl class="function">
<dt id="numpy.zeros_like"><span class="yiyi-st" id="yiyi-13"> <code class="descclassname">numpy.</code><code class="descname">zeros_like</code><span class="sig-paren">(</span><em>a</em>, <em>dtype=None</em>, <em>order=&apos;K&apos;</em>, <em>subok=True</em><span class="sig-paren">)</span><a class="reference external" href="http://github.com/numpy/numpy/blob/v1.11.3/numpy/core/numeric.py#L86-L146"><span class="viewcode-link">[source]</span></a></span></dt>
<dd><p><span class="yiyi-st" id="yiyi-14">返回具有与给定数组相同的形状和类型的零数组。</span></p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name">
<col class="field-body">
<tbody valign="top">
<tr class="field-odd field"><th class="field-name"><span class="yiyi-st" id="yiyi-15">参数：</span></th><td class="field-body"><p class="first"><span class="yiyi-st" id="yiyi-16"><strong>a</strong>：array_like</span></p>
<blockquote>
<div><p><span class="yiyi-st" id="yiyi-17"><em class="xref py py-obj">a的形状和数据类型定义返回的数组的这些相同的属性。</em></span></p>
</div></blockquote>
<p><span class="yiyi-st" id="yiyi-18"><strong>dtype</strong>：数据类型，可选</span></p>
<blockquote>
<div><p><span class="yiyi-st" id="yiyi-19">覆盖结果的数据类型。</span></p>
<div class="versionadded">
<p><span class="yiyi-st" id="yiyi-20"><span class="versionmodified">版本1.6.0中的新功能。</span></span></p>
</div>
</div></blockquote>
<p><span class="yiyi-st" id="yiyi-21"><strong>order</strong>：{&apos;C&apos;，&apos;F&apos;，&apos;A&apos;或&apos;K&apos;}，可选</span></p>
<blockquote>
<div><p><span class="yiyi-st" id="yiyi-22">覆盖结果的内存布局。</span><span class="yiyi-st" id="yiyi-23">&apos;C&apos;表示C阶，&apos;F&apos;表示F阶，&apos;A&apos;表示如果<em class="xref py py-obj">a</em>是Fortran连续的&apos;F&apos;，否则为&apos;C&apos;。</span><span class="yiyi-st" id="yiyi-24">&apos;K&apos;表示尽可能接近<em class="xref py py-obj">a</em>的布局。</span></p>
<div class="versionadded">
<p><span class="yiyi-st" id="yiyi-25"><span class="versionmodified">版本1.6.0中的新功能。</span></span></p>
</div>
</div></blockquote>
<p><span class="yiyi-st" id="yiyi-26"><strong>subok</strong>：bool，可选。</span></p>
<blockquote>
<div><p><span class="yiyi-st" id="yiyi-27">如果为True，那么新创建的数组将使用子类类型&apos;a&apos;，否则将是一个基类数组。</span><span class="yiyi-st" id="yiyi-28">默认为True。</span></p>
</div></blockquote>
</td>
</tr>
<tr class="field-even field"><th class="field-name"><span class="yiyi-st" id="yiyi-29">返回：</span></th><td class="field-body"><p class="first"><span class="yiyi-st" id="yiyi-30"><strong>out</strong>：ndarray</span></p>
<blockquote class="last">
<div><p><span class="yiyi-st" id="yiyi-31">具有与<em class="xref py py-obj">a</em>相同形状和类型的零数组。</span></p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title"><span class="yiyi-st" id="yiyi-32">也可以看看</span></p>
<dl class="last docutils">
<dt><span class="yiyi-st" id="yiyi-33"><a class="reference internal" href="numpy.ones_like.html#numpy.ones_like" title="numpy.ones_like"><code class="xref py py-obj docutils literal"><span class="pre">ones_like</span></code></a></span></dt>
<dd><span class="yiyi-st" id="yiyi-34">返回具有输入的形状和类型的数组。</span></dd>
<dt><span class="yiyi-st" id="yiyi-35"><a class="reference internal" href="numpy.empty_like.html#numpy.empty_like" title="numpy.empty_like"><code class="xref py py-obj docutils literal"><span class="pre">empty_like</span></code></a></span></dt>
<dd><span class="yiyi-st" id="yiyi-36">返回一个具有输入形状和类型的空数组。</span></dd>
<dt><span class="yiyi-st" id="yiyi-37"><a class="reference internal" href="numpy.zeros.html#numpy.zeros" title="numpy.zeros"><code class="xref py py-obj docutils literal"><span class="pre">zeros</span></code></a></span></dt>
<dd><span class="yiyi-st" id="yiyi-38">将新的数组设置值返回为零。</span></dd>
<dt><span class="yiyi-st" id="yiyi-39"><a class="reference internal" href="numpy.ones.html#numpy.ones" title="numpy.ones"><code class="xref py py-obj docutils literal"><span class="pre">ones</span></code></a></span></dt>
<dd><span class="yiyi-st" id="yiyi-40">将新的数组设置值返回为1。</span></dd>
<dt><span class="yiyi-st" id="yiyi-41"><a class="reference internal" href="numpy.empty.html#numpy.empty" title="numpy.empty"><code class="xref py py-obj docutils literal"><span class="pre">empty</span></code></a></span></dt>
<dd><span class="yiyi-st" id="yiyi-42">返回一个新的未初始化数组。</span></dd>
</dl>
</div>
<p class="rubric"><span class="yiyi-st" id="yiyi-43">例子</span></p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">x</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">6</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">x</span> <span class="o">=</span> <span class="n">x</span><span class="o">.</span><span class="n">reshape</span><span class="p">((</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">x</span>
<span class="go">array([[0, 1, 2],</span>
<span class="go">       [3, 4, 5]])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">np</span><span class="o">.</span><span class="n">zeros_like</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
<span class="go">array([[0, 0, 0],</span>
<span class="go">       [0, 0, 0]])</span>
</pre></div>
</div>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">y</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="n">np</span><span class="o">.</span><span class="n">float</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">y</span>
<span class="go">array([ 0.,  1.,  2.])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">np</span><span class="o">.</span><span class="n">zeros_like</span><span class="p">(</span><span class="n">y</span><span class="p">)</span>
<span class="go">array([ 0.,  0.,  0.])</span>
</pre></div>
</div>
</dd></dl>
